home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.3 KB | 271 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWODGeom.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwodutil
- #endif
-
- //========================================================================================
- // Globales
- //========================================================================================
-
- // [HLX] We need to release them when the library is unloaded
- ODShape* FW_gShapeMaker = NULL;
- ODTransform* FW_gTransformMaker = NULL;
-
- //========================================================================================
- // Globales Methods
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // ::PrivCreateShapeTransformMaker
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR void FW_PrivCreateShapeTransformMaker(Environment *ev, ODFrame* odFrame)
- {
- if (FW_gShapeMaker == NULL)
- {
- FW_gShapeMaker = odFrame->CreateShape(ev);
-
- FW_gShapeMaker->SetRectangle(ev, (ODRect*) &FW_kZeroRect);
- }
-
- if (FW_gTransformMaker == NULL)
- FW_gTransformMaker = odFrame->CreateTransform(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_NewODShape
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODShape* FW_NewODShape_Empty(Environment* ev)
- {
- FW_ASSERT(FW_gShapeMaker != NULL);
- return FW_gShapeMaker->NewShape(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODShape
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODShape* FW_NewODShape_PlatformRect(Environment *ev, const FW_SPlatformRect& rect)
- {
- return FW_NewODShape(ev, FW_CRect(rect));
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODShape
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODShape* FW_NewODShape_Rect(Environment *ev, const FW_CRect& rect)
- {
- ODShape *odShape = NULL;
- FW_VOLATILE(odShape);
-
- FW_TRY
- {
- odShape = ::FW_NewODShape(ev);
- odShape->SetRectangle(ev, (ODRect*) &rect);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
-
- if (odShape!=NULL)
- odShape->Release(ev);
-
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- return odShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODShape
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODShape* FW_NewODShape_Region(Environment *ev, ODRgnHandle rgnHandleToAdopt)
- {
- ODShape *odShape = NULL;
- FW_VOLATILE(odShape);
-
- FW_TRY
- {
- odShape = ::FW_NewODShape(ev);
- FW_SetShapeRegion(ev, odShape, rgnHandleToAdopt);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- if (odShape!=NULL)
- odShape->Release(ev);
-
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- return odShape;
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODShape
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODShape* FW_NewODShape_Shape(Environment *ev, ODShape* otherShape)
- {
- return otherShape->Copy(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_NewODTransform
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODTransform* FW_NewODTransform_Empty(Environment* ev)
- {
- FW_ASSERT(FW_gTransformMaker != NULL);
- return FW_gTransformMaker->NewTransform(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODTransform
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODTransform* FW_NewODTransform_Transform(Environment *ev, ODTransform* otherTransform)
- {
- return otherTransform->Copy(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODTransform
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODTransform* FW_NewODTransform_Point(Environment *ev, const FW_CPoint& offset)
- {
- ODTransform *odTransform = NULL;
- FW_VOLATILE(odTransform);
-
- FW_TRY
- {
- odTransform = ::FW_NewODTransform(ev);
- odTransform->MoveBy(ev, (ODPoint*)&offset);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- if (odTransform)
- odTransform->Release(ev);
-
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- return odTransform;
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_NewODTransform
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODTransform* FW_NewODTransform_Point2(Environment *ev, const FW_CPoint& offset, const FW_CPoint& scale)
- {
- ODTransform *odTransform = NULL;
- FW_VOLATILE(odTransform);
-
- FW_TRY
- {
- odTransform = ::FW_NewODTransform(ev);
- odTransform->ScaleBy(ev, (ODPoint*)&scale);
- odTransform->MoveBy(ev, (ODPoint*)&offset);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- if (odTransform)
- odTransform->Release(ev);
-
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- return odTransform;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_GetShapeRegion
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR ODRgnHandle FW_GetShapeRegion(Environment *ev, ODShape* odShape)
- {
- #ifdef FW_BUILD_MAC
- return odShape->GetQDRegion(ev);
- #endif
- #ifdef FW_BUILD_WIN
- return odShape->GetWinRegion(ev);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SetShapeRegion
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR void FW_SetShapeRegion(Environment *ev, ODShape* odShape, ODRgnHandle rgnHandle)
- {
- #ifdef FW_BUILD_MAC
- odShape->SetQDRegion(ev, rgnHandle);
- #endif
- #ifdef FW_BUILD_WIN
- odShape->SetWinRegion(ev, rgnHandle);
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_GetShapeBoundingBox
- //----------------------------------------------------------------------------------------
-
- FW_FUNC_ATTR FW_CRect FW_GetShapeBoundingBox(Environment *ev, ODShape* odShape)
- {
- ODRect rect;
- odShape->GetBoundingBox(ev, &rect);
- return rect;
- }
-